package com.lottery.im.module.result.presenter;

import android.app.Activity;
import com.lottery.im.api.ApiClient;
import com.lottery.im.api.observer.BaseListObserver;
import com.lottery.im.api.result.entity.GameHistoryInfo;
import com.lottery.im.base.BaseFragmentPresenter;
import com.lottery.im.module.result.view.WinStatisticsView;
import com.trello.rxlifecycle2.LifecycleProvider;
import com.trello.rxlifecycle2.android.FragmentEvent;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class WinStatisticsPresenter extends BaseFragmentPresenter<WinStatisticsView> {

  public WinStatisticsPresenter(Activity activity, WinStatisticsView iView,
      LifecycleProvider<FragmentEvent> provider) {
    super(activity, iView, provider);
  }

  /*
   * 查询单个彩种开奖结果-预测
   * */
  public void queryGameTypeResult(String gameType, int startRow, int pageSize) {
    ApiClient.getApiRetrofitInstance()
        .queryGameTypeResult(gameType, startRow, pageSize)
        .throttleFirst(2, TimeUnit.SECONDS)
        .subscribeOn(Schedulers.io())
        .observeOn(AndroidSchedulers.mainThread())
        .compose(provider.bindToLifecycle())
        .subscribe(new BaseListObserver<GameHistoryInfo>() {
                     @Override public void onStart() {
                     }

                     @Override public void onSuccess(List<GameHistoryInfo> list) {
                       iView.queryHistorySuccess(list);
                     }

                     @Override public void onFail(String code, String msg) {
                     }

                     @Override public void onException(String msg) {
                     }

                     @Override public void onFinish() {
                     }
                   }
        );
  }
}
